package cj.web.uc.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cj.web.uc.dao.PayHistoryDAO;
import cj.web.uc.dao.WatchHistoryDAO;
import cj.web.yc.dao.VideoOrderDAO;

@Service
public class VideoUcService {

	@Autowired
    private WatchHistoryDAO watchHistoryDAO;
	
	@Autowired
    private PayHistoryDAO payHistoryDAO;
	
	@Autowired
    private VideoOrderDAO videoOrderDAO;
	
	/**
	 * 创建订单
	 * @param id
	 * @param orderNo
	 * @param memberId
	 * @param price
	 * @param status
	 * @param createUser
	 * @param updateUser
	 * @return
	 */
	public int createOrder(int id,String orderNo,int memberId,String price,int status,String createUser,String updateUser){
		return videoOrderDAO.create(id, orderNo, memberId, price, status, createUser, updateUser);
	}
	
	public List<Map> queryWatchHistory(int memberId,int start,int length){
		return watchHistoryDAO.query(memberId, start, length);
	}
	
	/**
	 * 查询
	 * @param watchHistory
	 * @return watchHistorylis;size
	 */
	public Map queryWatchHistorylis(int memberId,int start,int length){
		Map rep = new HashMap();
		List<Map> watchHistorylis = watchHistoryDAO.query(memberId, start, length);
		int size = watchHistoryDAO.querySize(memberId); 
		rep.put("watchHistorylis", watchHistorylis);
		rep.put("size", size);
		return rep;
    }
	
	/**
	 * 查询
	 * @param payHistory
	 * @return payHistorylis;size
	 */
	public Map queryPayHistorylis(int memberId,int start,int length){
		Map rep = new HashMap();
		List<Map> payHistorylis = payHistoryDAO.query(memberId, start, length);
		int size = payHistoryDAO.querySize(memberId); 
		rep.put("payHistorylis", payHistorylis);
		rep.put("size", size);
		return rep;
    }
}